package com.neusoft.elm.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;



public class DBUtil {

	private static String driver ="com.mysql.jdbc.Driver";
	private static String URL = "jdbc:mysql://127.0.0.1:3306/elm_admin";
	private static String USERNAME ="root";
	private static String PASSWORD ="1234";
	
	
	
		//�������ݿ�����
		public static Connection getConnection(){
			Connection con =null;
			try {
				Class.forName(driver);
				con=DriverManager.getConnection(URL,USERNAME,PASSWORD);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return con;
		}
		public static void closeAll(ResultSet rs,PreparedStatement pst,Connection con){
			try{
				if(rs!=null){
					rs.close();	 
				}
				if(pst!=null){
					pst.close();
				}
				if(con!=null){
					con.close();
				}
			}
			catch(SQLException e){
				e.printStackTrace();
			}
		}
		
	

}
